import request from '@/utils/request'
import { otherFiltersItem } from '@/utils'

/**
 * 查询详情
 * @param {string} id id
 */
export function queryById(id) {
  return request({
    url: `/api/v1/channelTask/${id}`,
    method: 'get'
  })
}

/**
 * 保存
 * @param {Object} data
 * @returns
 */
export function saveData(data) {
  return request({
    url: `/api/v1/channelTask`,
    method: data.id ? 'put' : 'post',
    data
  })
}

/**
 * 查询每日填报详情
 * @param {string} channelTaskCode channelTaskCode
 */
export function queryDailyFill(channelTaskCode) {
  const data = new FormData()
  data.append('pageFlag', false)
  data.append('filtersRaw', JSON.stringify([otherFiltersItem('channelTaskCode', channelTaskCode, '=')]))
  return request({
    url: `/api/v1/customerManagerDailyFill/page`,
    method: 'post',
    data
  })
}

/**
 * 保存每日填报
 * @param {Object} data
 * @returns
 */
export function saveDailyData(data) {
  return request({
    url: `/api/v1/customerManagerDailyFill`,
    method: data.id ? 'put' : 'post',
    data
  })
}
